package com.gears_software.sxdc.dccx.data.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;


import com.gears_software.sxdc.dccx.data.model.PositionEntity;
import com.gears_software.sxdc.dccx.ui.view.RecomandAddressItemView;
import com.gears_software.sxdc.dccx.ui.view.RecomandAddressItemView_;

import java.util.List;

/**
 * Created by chezhenzhen on 2017/6/7.
 * 显示的poi列表
 */

public class RecomandAddressAdapter extends BaseAdapter {

    private Context context;
    private List<PositionEntity> positionEntitiesList;

    public RecomandAddressAdapter(Context context, List<PositionEntity> positionEntitiesList) {
        super();
        this.context = context;
        this.positionEntitiesList = positionEntitiesList;
    }

    public void setPositionEntitiesList(List<PositionEntity> entities) {
        this.positionEntitiesList = entities;
    }

    @Override
    public int getCount() {
        return positionEntitiesList.size();
    }

    @Override
    public Object getItem(int position) {
        return positionEntitiesList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        RecomandAddressItemView itemView = null;
        if (convertView == null) {
            itemView = RecomandAddressItemView_.build(context);
        } else {
            itemView = (RecomandAddressItemView) convertView;
        }
        itemView.bind(positionEntitiesList.get(position));
        return itemView;
    }
}
